window.onload = function () {
    let toggleMore = document.getElementById('toggle-more');
    let toggleLess = document.getElementById('toggle-less');
    let otherOrder = document.querySelector('.other-order');
    const defaultItemsToShow = 6; // 默认显示的订单项数量
    let isExpanded = false; // 标记是否展开

    const orderItems = otherOrder.querySelectorAll('li');
    const length=11;

    // 初始隐藏多余的订单项
    for (let i = defaultItemsToShow; i < length; i++) {
        orderItems[i].style.display = 'none';
    }
    toggleMore.onclick = function () {
        if (!isExpanded) {
            // 展开全部订单项
            for (let i = defaultItemsToShow; i < length; i++) {
                orderItems[i].style.display = 'flex';
            }
            toggleMore.style.display = 'none'; // 隐藏“查看更多”链接
            toggleLess.style.display = 'inline-block'; // 显示“收起”链接
            isExpanded = true; // 更新展开状态
            otherOrder.classList.add('expanded');
        }
    }
    toggleLess.onclick = function () {
        if (isExpanded) {
            // 收起多余的订单项
            for (let i = defaultItemsToShow; i < length; i++) {
                orderItems[i].style.display = 'none';
            }
            toggleLess.style.display = 'none'; // 隐藏“收起”链接
            toggleMore.style.display = 'inline-block'; // 显示“查看更多”链接
            isExpanded = false; // 更新展开状态
            otherOrder.classList.remove('expanded');
        }
    }
}


